package com.bdzl.daoRepository;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.bdzl.pojo.Clause;
import com.bdzl.pojo.Company;


public interface ClauseDao extends JpaRepository<Clause, Integer> {
	
	
	@Query(" select c from  Clause c  where  c.type = :type and  CONCAT(name,number,search_name ) LIKE %:search% ")
	List<Clause> findbdTj(@Param("type")Integer type,@Param("search") String search,Pageable pageAble );


	@Query(" select c from  Clause c  where  CONCAT( name , number , search_name ) LIKE %:search% ")
	List<Clause> findbdTj3(@Param("search")String search,Pageable pageAble);


	@Query(" select c from  Clause c  where c.company = :com and c.type = :type  and CONCAT( name , number , search_name ) LIKE %:search% ")
	List<Clause> findbdTj2(@Param("com")Company com,@Param("type") Integer type,@Param("search") String search,Pageable pageAble);


	@Query(" select c from  Clause c  where c.company = :com and  CONCAT( name , number , search_name ) LIKE %:search% ")
	List<Clause> findbdtj4(@Param("com")Company com,@Param("search") String search,Pageable pageAble);


	
	Clause findById(Integer insuranceId);

	@Modifying
	@Query(" update Clause set  state = 0 , endTime = :now , endUser = :adminId  where id = :id ")
	void update(@Param("id")Integer insuranceId,@Param("now")Long  now,@Param("adminId")Integer adminId);

}
